package com.zyg.modules.report.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zyg.modules.report.entity.JournalEntity;
import com.zyg.modules.report.service.JournalService;
import com.zyg.common.utils.PageUtils;
import com.zyg.common.utils.ResultData;



/**
 * 每日报表
 *
 * @author shenmh
 * @date 2021-01-07 12:50:44
 */
@RestController
@RequestMapping("report/journal")
public class JournalController {
    @Autowired
    private JournalService journalService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("report:journal:list")
    public ResultData list(@RequestParam Map<String, Object> params){
        PageUtils page = journalService.queryPage(params);

        return ResultData.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("report:journal:info")
    public ResultData info(@PathVariable("id") Integer id){
		JournalEntity journal = journalService.getById(id);

        return ResultData.ok().put("journal", journal);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("report:journal:save")
    public ResultData save(@RequestBody JournalEntity journal){
		journalService.save(journal);

        return ResultData.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("report:journal:update")
    public ResultData update(@RequestBody JournalEntity journal){
		journalService.updateById(journal);

        return ResultData.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("report:journal:delete")
    public ResultData delete(@RequestBody Integer[] ids){
		journalService.removeByIds(Arrays.asList(ids));

        return ResultData.ok();
    }

}
